home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
CLOBSS.PAK
/
SORTARRY.CPO
< prev
next >
Wrap
Text File
|
1997-05-06
|
2KB
|
64 lines
/*------------------------------------------------------------------------*/
/* */
/* SORTARRY.CPP */
/* */
/* Copyright Borland International 1991, 1996 */
/* All Rights Reserved */
/* */
/*------------------------------------------------------------------------*/
#if !defined( __STDLIB_H )
#include <stdlib.h>
#endif // __STDLIB_H
#if !defined( __IOSTREAM_H )
#include <iostream.h>
#endif // __IOSTREAM_H
#if !defined( __SORTARRY_H )
#include "classlib\obsolete\sortarry.h"
#endif // __SORTARRY_H
void SortedArray::add( Object& toAdd )
{
if( toAdd.isSortable() )
{
if( lastElementIndex == upperbound )
{
reallocate( arraySize() + 1 );
}
int insertionPoint = lowerbound;
while( insertionPoint <= lastElementIndex &&
(Sortable&)objectAt( insertionPoint ) < (Sortable&)toAdd
)
insertionPoint++;
insertEntry( insertionPoint );
setData( insertionPoint, &toAdd );
itemsInContainer++;
lastElementIndex++;
}
else
ClassLib_error( __ENOTSORT );
}
void SortedArray::detach( int loc, DeleteType dt )
{
if( loc != INT_MIN )
{
if( delObj(dt) )
delete ptrAt( loc );
removeEntry( loc );
itemsInContainer--;
if( loc <= lastElementIndex )
lastElementIndex--;
}
}
void SortedArray::detach( Object& toDetach, DeleteType dt )
{
int detachPoint = find( toDetach );
detach( detachPoint, dt );
}